/**
 * Created by zhangligang
 * Email: tzhang2450@163.com
 * Date: 2018/11/26
 * Time: 11:16
 */
$(function(){
    var authorization = Cookies.get('_token');
    var params = {id: id};
    $.ajax({
        type: 'get',
        url: '/v1/manager/get/user.json',
        headers: {
            Authorization: authorization,
            Accept: "application/json; charset=utf-8"
        },
        data: {params: params},
        success: function(e){
            var data = JSON.parse(e);
            if (data.status == 200) {
                var json = data.body.data;
                $('.username').text(json.username);
            }
        }
    });

    $('.btn-save').on('click', function(){
        var params = {
            id: $('.user-id').val(),
            password: $('.password').val()
        };
        $.ajax({
            type: 'post',
            url: '/v1/manager/saveUser',
            headers: {
                Authorization: authorization,
                Accept: "application/json; charset=utf-8"
            },
            data: {params: params},
            success: function(e){
                var data = JSON.parse(e);
                if (data.status == 200) {
                    alert('更新成功!');
                    location.href = '/manager/user.html';
                }
            }
        });
    });
});
